class CreateVoucherTransactionLogPartitions < ActiveRecord::Migration
  def change
    execute 'alter table voucher_transaction_logs drop primary key, add primary key(id, transaction_datetime);'
    execute <<-SQL
        ALTER TABLE voucher_transaction_logs PARTITION BY RANGE COLUMNS (transaction_datetime)(
           PARTITION p8 VALUES LESS THAN ('2014-08-01'),
           PARTITION p9 VALUES LESS THAN ('2014-09-01'),
           PARTITION p10 VALUES LESS THAN ('2014-10-01'),
           PARTITION p11 VALUES LESS THAN ('2014-11-01'),
           PARTITION p12 VALUES LESS THAN ('2014-12-01'),
           PARTITION p13 VALUES LESS THAN ('2015-01-01'),
           PARTITION p14 VALUES LESS THAN ('2015-02-01'),
           PARTITION p15 VALUES LESS THAN ('2015-03-01'),
           PARTITION p16 VALUES LESS THAN ('2015-04-01'),
           PARTITION p17 VALUES LESS THAN ('2015-05-01'),
           PARTITION p18 VALUES LESS THAN ('2015-06-01'),
           PARTITION p19 VALUES LESS THAN ('2015-07-01'),
           PARTITION p20 VALUES LESS THAN ('2015-08-01'),
           PARTITION p21 VALUES LESS THAN ('2015-09-01'),
           PARTITION p22 VALUES LESS THAN ('2015-10-01'),
           PARTITION p23 VALUES LESS THAN ('2015-11-01'),
           PARTITION p24 VALUES LESS THAN ('2015-12-01'),
           PARTITION p25 VALUES LESS THAN ('2016-01-01'),
           PARTITION p26 VALUES LESS THAN ('2016-02-01'),
           PARTITION p27 VALUES LESS THAN ('2016-03-01'),
           PARTITION p28 VALUES LESS THAN ('2016-04-01'),
           PARTITION p29 VALUES LESS THAN ('2016-05-01'),
           PARTITION p30 VALUES LESS THAN ('2016-06-01'),
           PARTITION p31 VALUES LESS THAN ('2016-07-01'),
           PARTITION p32 VALUES LESS THAN ('2016-08-01'),
           PARTITION p33 VALUES LESS THAN ('2016-09-01'),
           PARTITION p34 VALUES LESS THAN ('2016-10-01'),
           PARTITION p35 VALUES LESS THAN ('2016-11-01'),
           PARTITION p36 VALUES LESS THAN ('2016-12-01'),
           PARTITION p37 VALUES LESS THAN ('2017-01-01'),
           PARTITION p38 VALUES LESS THAN ('2017-02-01'),
           PARTITION p39 VALUES LESS THAN ('2017-03-01'),
           PARTITION p40 VALUES LESS THAN ('2017-04-01'),
           PARTITION p41 VALUES LESS THAN ('2017-05-01'),
           PARTITION p42 VALUES LESS THAN ('2017-06-01'),
           PARTITION p43 VALUES LESS THAN ('2017-07-01'),
           PARTITION p44 VALUES LESS THAN ('2017-08-01'),
           PARTITION p45 VALUES LESS THAN ('2017-09-01'),
           PARTITION p46 VALUES LESS THAN ('2017-10-01'),
           PARTITION p47 VALUES LESS THAN ('2017-11-01'),
           PARTITION p48 VALUES LESS THAN ('2017-12-01'),
           PARTITION p49 VALUES LESS THAN MAXVALUE
        );
    SQL
  end
end
